package com.school.hjt.schoolclasscard.utlis;

import android.app.Dialog;
import android.content.Context;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;


import com.bumptech.glide.Glide;
import com.school.hjt.schoolclasscard.R;
import com.school.hjt.schoolclasscard.view.CircleImageView;

import java.util.List;

/**
 * Created by xqx on 2017/11/10.
 *
 */

public class DialogUtlis {
//    public static  Dialog dialog;
    public static void showStudentDialog(final Context contxt,String url) {
        final Dialog dialog= new Dialog(contxt, R.style.ActionSheetDialogStyle);
        dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
        dialog.setCanceledOnTouchOutside(true);
        dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        //填充对话框的布
        View inflate = LayoutInflater.from(contxt).inflate(R.layout.dialog_studentqd, null);
        TextView tv_time=  inflate.findViewById(R.id.tv_time);
        TextView tv_Sign=  inflate.findViewById(R.id.tv_Sign);
        CircleImageView civ_icon=  inflate.findViewById(R.id.civ_icon);
//        if (!cardStudent.getStudent_url().equals("无头像")) {
//            Glide.with(contxt).load(cardStudent.getStudent_url()).error(R.mipmap.student).into(civ_icon);
//        }
//        TextView tv_studentName= (TextView) inflate.findViewById(R.id.tv_studentName);
        tv_Sign.setText("签到成功");
        tv_time.setText("刷卡时间 "+ ClassCalendar.getIntTimes());
        if (!url.equals("")){
            Glide.with(contxt).load(url).error(R.mipmap.student).into(civ_icon);
        }else{
            civ_icon.setImageResource(R.mipmap.student);
        }
        dialog.setContentView(inflate);

        dialog.show();//显示对话框
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                dialog.dismiss();
            }
        },2000);
    }
}
